import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {LoginComponent} from './base/login/login.component';
import {RegisterComponent} from './base/register/register.component';
import {AppComponent} from './app.component';
import {HomeComponent} from './home/home.component';
import {DefaultPageComponent} from './home/default-page/default-page.component';
import {BaseRouteFilter} from './base/base-route.filter';
import {ForgetComponent} from './base/forget/forget.component';
import {ShareFileComponent} from './base/share-file/share-file.component';

const routes: Routes = [
  {
    path: '',
    data: {title: '请购单管理'},
    component: AppComponent,
    children: [
      {path: '', redirectTo: 'login', pathMatch: 'full'},
      {path: 'login', component: LoginComponent},
      {path: 'register', component: RegisterComponent},
      {path: 'forget', component: ForgetComponent},
      {path: 'share/:code', component: ShareFileComponent},
      {
        path: 'archive',
        component: DefaultPageComponent
      },
      {
        path: 'home', component: HomeComponent, canActivate: [BaseRouteFilter],
        children: [
          {
            path: '',
            component: DefaultPageComponent
          },
          {
            path: 'file',
            loadChildren: 'src/app/home/file-management/file-management.module#FileManagementModule'
          },
          {
            path: 'blog',
            loadChildren: 'src/app/home/blog-management/blog-management.module#BlogManagementModule'
          }
        ]
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {useHash: true})],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
